import { IsOptional, IsString, IsNumber, IsBoolean, IsEnum, IsUrl, Min, Max, IsObject } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class UpdateMenuDto {
  @ApiProperty({
    description: '菜单名称',
    example: '更新后的菜单名称',
    required: false,
    maxLength: 100
  })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiProperty({
    description: '菜单路径',
    example: '/updated-menu',
    required: false,
    maxLength: 200
  })
  @IsOptional()
  @IsString()
  path?: string;

  @ApiProperty({
    description: '前端组件路径',
    example: 'updated-menu/index',
    required: false,
    maxLength: 200
  })
  @IsOptional()
  @IsString()
  component?: string;

  @ApiProperty({
    description: '菜单图标',
    example: 'edit',
    required: false,
    maxLength: 100
  })
  @IsOptional()
  @IsString()
  icon?: string;

  @ApiProperty({
    description: '排序权重',
    example: 5,
    required: false,
    minimum: 0,
    maximum: 999
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(999)
  sort?: number;

  @ApiProperty({
    description: '父菜单ID',
    example: 0,
    required: false
  })
  @IsOptional()
  @IsNumber()
  parent_id?: number;

  @ApiProperty({
    description: '菜单层级',
    example: 2,
    required: false
  })
  @IsOptional()
  @IsNumber()
  level?: number;

  @ApiProperty({
    description: '菜单类型',
    example: 'menu',
    enum: ['menu', 'button'],
    required: false
  })
  @IsOptional()
  @IsEnum(['menu', 'button'])
  type?: 'menu' | 'button';

  @ApiProperty({
    description: '权限标识',
    example: 'updated:menu',
    required: false,
    maxLength: 200
  })
  @IsOptional()
  @IsString()
  permission?: string;

  @ApiProperty({
    description: '是否可见',
    example: true,
    required: false
  })
  @IsOptional()
  @IsBoolean()
  is_visible?: boolean;

  @ApiProperty({
    description: '是否启用',
    example: true,
    required: false
  })
  @IsOptional()
  @IsBoolean()
  is_enabled?: boolean;

  @ApiProperty({
    description: '外部链接',
    example: 'https://example.com',
    required: false,
    maxLength: 500
  })
  @IsOptional()
  @IsUrl()
  external_link?: string;

  @ApiProperty({
    description: '打开方式',
    example: '_self',
    enum: ['_self', '_blank', '_parent', '_top'],
    required: false
  })
  @IsOptional()
  @IsEnum(['_self', '_blank', '_parent', '_top'])
  target?: '_self' | '_blank' | '_parent' | '_top';

  @ApiProperty({
    description: '元数据信息',
    example: { title: '更新后的菜单', keepAlive: true },
    required: false
  })
  @IsOptional()
  @IsObject()
  meta?: any;
}
